package com.codegzy.service;

import com.codegzy.dao.EmployeeDao;
import com.codegzy.entity.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class EmployeeServiceImpl implements EmployeeService {

    @Autowired
    private EmployeeDao employeeDao;

    @Override
    public List<Employee> findAll() {
        return employeeDao.selectList(null);
    }

    @Override
    public int save(Employee employee) {
        return employeeDao.insert(employee);
    }

    @Override
    public Employee findById(Integer id) {
        return employeeDao.selectById(id);
    }

    @Override
    public int updateEmployee(Employee employee) {
        return employeeDao.updateById(employee);
    }

    @Override
    public int delete(Integer id) {
        return employeeDao.deleteById(id);
    }
}
